//
//  ReportViewModel.m
//  ForYourBeauty
//
//  Created by Kelly xu on 2019/6/3.
//  Copyright © 2019 changrenTech. All rights reserved.
//

#import "ReportViewModel.h"

@implementation ReportViewModel
-(void)fetchReportList:(BOOL)alreadyHandle cmp:(void(^)(NSMutableArray *reportList))cmp{
    [[HttpClient shareClient]postWithUrl:REPORTLIST params:@{@"blurSearch":@{},@"order": @{},@"p": @(0),@"search": @{@"reportType":alreadyHandle?@"0":@"1"},@"size": @(10)} suc:^(id results) {
        NSArray *list = [results objectForKey:@"resultList"];
        NSMutableArray *reportlist = [[NSMutableArray alloc]init];
        for (NSDictionary *item in list) {
            [reportlist addObject:[ReportListModel modelObjectWithDictionary:item]];
        }
        cmp(reportlist);
    } fail:^(NSString *error, NSInteger status) {
        Toast(error);
    }];
}
-(void)addReport:(NSString*)beforeImg beforeTime:(NSString*)beforeTime afterImg:(NSString*)afterImg afterTime:(NSString*)afterTime addTime:(NSString*)addTime cmp:(void(^)())cmp{
    [[HttpClient shareClient] postWithUrl:ADD_REPORT params:@{@"addTime":addTime,@"beganImg":beforeImg,@"beganTime":beforeTime,@"endImg":afterImg,@"endTime":afterTime,@"userId":[LoginTools sharedTools].userId} suc:^(id results) {
        cmp();
    } fail:^(NSString *error, NSInteger status) {
        Toast(error);
    }];
}
@end
